package com.hishop.product.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.hishop.common.validator.group.AddGroup;
import com.hishop.common.validator.group.ListValue;
import com.hishop.common.validator.group.UpdateGroup;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;
import java.io.Serializable;

/**
 * 品牌
 * 
 * @author tanwenbin
 * @email 2466082499@qq.com
 * @date 2024-03-13 09:24:45
 */
@Data
@TableName("pms_brand")
public class BrandEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * 品牌id
	 *
	 * @NotNull @Null 分组（分情况）校验
	 *
	 */
	@NotNull(message = "修改必须指定品牌id",groups = {UpdateGroup.class})
	@Null(message = "新增不能指定id",groups = {AddGroup.class})
	@TableId
	private Long brandId;
	/**
	 * 品牌名
	 */
	// 校验注解，判断是否为空 这个包 javax.validation，message问题提示（品牌名新增、修改都要有）
	@NotBlank(message = "品牌名必须提交，不能为空！",groups = {UpdateGroup.class, AddGroup.class})
	private String name;
	/**
	 * 品牌logo地址
	 */
	@NotEmpty(groups = {AddGroup.class})
	@URL(message = "logo地址必须是一个合法的url",groups = {UpdateGroup.class, AddGroup.class})
	private String logo;
	/**
	 * 介绍
	 */
	private String descript;
	/**
	 * 显示状态[0-不显示；1-显示]
	 */
	@ListValue(vals = {0,1}, groups = {AddGroup.class})
	private Integer showStatus;
	/**
	 * 检索首字母"
	 */
	@NotNull(groups = {AddGroup.class})
	// 在这里写正则的时候不用前后两个斜杠 /^[a-zA-Z]$/
	@Pattern(regexp = "^[a-zA-Z]$",message = "检索必须是一个字母",groups = {UpdateGroup.class, AddGroup.class})
	private String firstLetter;
	/**
	 * 排序
	 */
	@NotNull(groups = {AddGroup.class})
	@Min(value = 0, message = "排序必须是一个大于0的整数",groups = {UpdateGroup.class, AddGroup.class})
	private Integer sort;

}
